package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.activity.recallplayer.data.RecallPlayerBeBindTaskValue;
import com.yanqu.road.entity.activity.recallplayer.data.RecallPlayerBindingTaskData;
import com.yanqu.road.entity.activity.recallplayer.data.RecallPlayerFloorCellData;
import com.yanqu.road.pb.activity.RecallPlayerProto;

import java.math.BigInteger;

public class RecallPlayerPb {
    public static RecallPlayerProto.BindingTaskData.Builder parseBindTaskMsg(RecallPlayerBindingTaskData bindingTaskData) {
        RecallPlayerProto.BindingTaskData.Builder taskBuilder = RecallPlayerProto.BindingTaskData.newBuilder();
        taskBuilder.setTaskId(bindingTaskData.getTaskId());
        taskBuilder.setTaskType(bindingTaskData.getTaskType());
        taskBuilder.setValue(bindingTaskData.getNowValue().toString());
        taskBuilder.setGotRewarded(bindingTaskData.getGotRewarded());
        taskBuilder.setOldValue(bindingTaskData.getOldValue().toString());
        return taskBuilder;
    }

    public static RecallPlayerProto.DrawFloorCellData.Builder parseDrawFloorCellMsg(RecallPlayerFloorCellData recallPlayerFloorCellData) {
        RecallPlayerProto.DrawFloorCellData.Builder cellBuilder = RecallPlayerProto.DrawFloorCellData.newBuilder();
        cellBuilder.setSpecial(recallPlayerFloorCellData.isSpecial());
        cellBuilder.setRemainingTimes(recallPlayerFloorCellData.getRemainingTimes());
        cellBuilder.setReward(recallPlayerFloorCellData.getReward());
        return cellBuilder;
    }

    public static RecallPlayerProto.BindTaskInfo.Builder parseBindTaskValueMsg(RecallPlayerBeBindTaskValue value) {
        RecallPlayerProto.BindTaskInfo.Builder taskBuilder = RecallPlayerProto.BindTaskInfo.newBuilder();
        taskBuilder.setTaskType(value.getTaskType());
        taskBuilder.setTaskValue(String.valueOf(value.getTaskValue()));
        taskBuilder.setTaskBindTimeValue(String.valueOf(value.getBindTimeValue()));
        taskBuilder.setNeedUpdate(value.isNeedUpdate());
        taskBuilder.setUpdateTime(value.getLastUpdateTime());
        return taskBuilder;
    }

    public static RecallPlayerBeBindTaskValue parseToBindTaskValue(RecallPlayerProto.BindTaskInfo msg){
        RecallPlayerBeBindTaskValue recallPlayerBeBindTaskValue = new RecallPlayerBeBindTaskValue();
        recallPlayerBeBindTaskValue.setTaskValue(BigInteger.valueOf(Long.parseLong(msg.getTaskValue())));
        recallPlayerBeBindTaskValue.setTaskType(msg.getTaskType());
        recallPlayerBeBindTaskValue.setBindTimeValue(BigInteger.valueOf(Long.parseLong(msg.getTaskBindTimeValue())));
        return recallPlayerBeBindTaskValue;
    }
}
